//////////////////////////////////////////////////////////////////////////
//
// GAM204
// Frustum
// Frustum.h
// 
// Grant Johnson
// Qantm College
// 27/10/2010
//
//////////////////////////////////////////////////////////////////////////

#ifndef FRUSTUM_H
#define FRUSTUM_H

#include "d3dx9.h"

class Node;

class Frustum
{
public:
	Frustum();
	~Frustum();

	//////////////////////////////////////////////////////////////////////////
	// Setup the array of frustum planes - each plane is normalized before
	// being set
	//
	// Paramaters:
	// a_left, the left plane
	// a_right, the right plane
	// a_top, the top plane
	// a_bottom, the bottom plane
	// a_near, the near plane
	// a_far, the far plane
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	void Setup(D3DXPLANE a_left, D3DXPLANE a_right, D3DXPLANE a_top, D3DXPLANE a_bottom, D3DXPLANE a_near, D3DXPLANE a_far);
	
	//////////////////////////////////////////////////////////////////////////
	// Checks to see if a node is colliding with the frustum. Loops through all
	// 6 planes, and does the dot product against each corner of the node
	//
	// Paramaters:
	// a_pNode, the node of which to check against the frustum
	//
	// Returns false if no collision was found
	// Returns true if a collision was found
	//
	//////////////////////////////////////////////////////////////////////////
	bool FrustumCollision(Node* a_pNode);

	D3DXPLANE GetPlane(int index) { return m_planes[index]; }

private:
	//An array of planes - makes it easier to check against the frustum
	D3DXPLANE m_planes[6];
};

#endif //FRUSTUM_H